import java.awt.event.*;

import java.awt.*;
import javax.swing.*; 


public class SuperTicTacToeGUI 
{
	
	public static void main(String[] args) 
	{
		JFrame frame = new JFrame(); 
		frame.setTitle("SuperTicTacToe");
		frame.setSize(600, 600);
		frame.setLocation(100,100);
		frame.setVisible(true);
		
		// Window Listeners
		frame.addWindowListener(new WindowAdapter() 
		{
		  	public void windowClosing(WindowEvent e) 
		  	{
			   System.exit(0);
		  	} //windowClosing
		} 
		);
		
		Container contentPane = frame.getContentPane(); 
		
		JPanel main = new JPanel(); 
		main.setLayout( new GridBagLayout() );
		main.setBackground(Color.WHITE);
		main.setVisible(true);
		contentPane.add(main);
		
		Dimension dim = frame.getSize(); 
		Insets in = frame.getInsets();
		
		System.out.println(dim.width + " " + dim.height);
		
		SubGrid testGrid = new SubGrid(0,0); 
		GridLocation loc = new GridLocation (0,0,0,0);
		testGrid.placePiece(new GamePiece(Color.BLUE, loc), loc);
		
		loc = new GridLocation (0,0,2, 1);
		testGrid.placePiece(new GamePiece(Color.BLUE, loc), loc);

		int width = dim.width - in.left - in.right;
		int height = dim.height - in.top - in.bottom; 
		
		int panelWidth = 100; 
		int panelHeight = 100; 
		
		GridBagConstraints c = new GridBagConstraints();
		c.insets = new Insets(20,20,20,20);
		
		JPanel panel = new GUI_SubGridPanel(testGrid); 
		panel.setPreferredSize(new Dimension(panelWidth, panelHeight));
		panel.setBackground(Color.WHITE);
		panel.setVisible(true);
		
		c.gridx = 0;
		c.gridy = 0;
		main.add(panel, c);
	
		JPanel panel2 = new GUI_SubGridPanel(testGrid); 
		panel2.setPreferredSize(new Dimension(panelWidth, panelHeight));
		panel2.setBackground(Color.WHITE);
		panel2.setVisible(true);
		
		c.gridx = 1;
		c.gridy = 0; 
		main.add(panel2, c);
		
		JPanel panel3 = new GUI_SubGridPanel(testGrid); 
		panel3.setPreferredSize(new Dimension(panelWidth, panelHeight));
		panel3.setBackground(Color.WHITE);
		panel3.setVisible(true);
		
		c.gridx = 2;
		c.gridy = 0; 
		main.add(panel3, c);
		
		JPanel panel4 = new GUI_SubGridPanel(testGrid); 
		panel4.setPreferredSize(new Dimension(panelWidth, panelHeight));
		panel4.setBackground(Color.WHITE);
		panel4.setVisible(true);
		
		c.gridx = 0;
		c.gridy = 1; 
		main.add(panel4, c);
		
		
		JPanel panel5 = new GUI_SubGridPanel(testGrid); 
		panel5.setPreferredSize(new Dimension(panelWidth, panelHeight));
		panel5.setBackground(Color.WHITE);
		panel5.setVisible(true);
		
		c.gridx = 1;
		c.gridy = 1; 
		main.add(panel5, c);
		
		JPanel panel6 = new GUI_SubGridPanel(testGrid); 
		panel6.setPreferredSize(new Dimension(panelWidth, panelHeight));
		panel6.setBackground(Color.WHITE);
		panel6.setVisible(true);
		
		c.gridx = 2;
		c.gridy = 1; 
		main.add(panel6, c);
		
		JPanel panel7 = new GUI_SubGridPanel(testGrid); 
		panel7.setPreferredSize(new Dimension(panelWidth, panelHeight));
		panel7.setBackground(Color.WHITE);
		panel7.setVisible(true);
		
		c.gridx = 0;
		c.gridy = 2; 
		main.add(panel7, c);
		
		JPanel panel8 = new GUI_SubGridPanel(testGrid); 
		panel8.setPreferredSize(new Dimension(panelWidth, panelHeight));
		panel8.setBackground(Color.WHITE);
		panel8.setVisible(true);
		
		c.gridx = 1;
		c.gridy = 2; 
		main.add(panel8, c);
		
		JPanel panel9 = new GUI_SubGridPanel(testGrid); 
		panel9.setPreferredSize(new Dimension(panelWidth, panelHeight));
		panel9.setBackground(Color.WHITE);
		panel9.setVisible(true);
		
		c.gridx = 2;
		c.gridy = 2; 
		main.add(panel9, c);
		frame.setVisible(true);
	}

}
